package com.codeoss.framework.view.renderer;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.ShortcutMenu;
import com.codeoss.framework.view.service.IShortcutMenuComponentService;

@Service("shortcutmenuRenderer")
public class ShortcutMenuRenderer extends CommonComponentRenderer {
	@Autowired
	private IShortcutMenuComponentService shortcutMenuComponentService;
	
	@Override
	protected void startRenderView(YunContext yunContext, Component component, ViewSerializeMap viewSerializeMap) {
		super.startRenderView(yunContext, component, viewSerializeMap);
		ShortcutMenu shortcutMenu=(ShortcutMenu)component;
		viewSerializeMap.put("title", shortcutMenu.getTitle());
		viewSerializeMap.put("col", shortcutMenu.getCol());
		viewSerializeMap.put("cols", shortcutMenu.getCols());
	}
	
	@Override
	protected PropSerializeMap startRenderProp(YunContext yunContext,
			Component component, ViewPropMap viewPropMap) {
		PropSerializeMap propSerializeMap=super.startRenderProp(yunContext, component, viewPropMap);
		List<Map<String,String>> mapList=shortcutMenuComponentService.getMenuList(yunContext, component);
		propSerializeMap.put("data", mapList);
		return propSerializeMap;
	}
}
